import { getScheduleItems } from './scheduleApi';

const mockData = {};
const USE_MOCK_API = false; // 设置为true以使用mock数据，false以使用真实API

export const getSchedule = async (date) => {
    if (USE_MOCK_API) {
        const dateString = date.toISOString().split('T')[0];
        if (!mockData[dateString]) {
            mockData[dateString] = [];
        }
        return mockData[dateString];
    } else {
        return await getScheduleItems(date);
    }
};

export const addEntry = async (date, entry) => {
    const dateString = date.toISOString().split('T')[0];
    if (!mockData[dateString]) {
        mockData[dateString] = [];
    }
    const newEntry = { id: mockData[dateString].length + 1, ...entry };
    mockData[dateString].push(newEntry);
    return newEntry;
};

export const deleteEntry = async (date, id) => {
    const dateString = date.toISOString().split('T')[0];
    if (mockData[dateString]) {
        mockData[dateString] = mockData[dateString].filter(entry => entry.id !== id);
    }
};